﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.franchise.display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import Display.aswingui.*;

    public class FranchisePhotoComponent extends JPanel {

        private var m_id:String;
        private var m_picContainer:DisplayObjectContainer;

        public function FranchisePhotoComponent(_arg1:String){
            super(new SoftBoxLayout(SoftBoxLayout.TOP));
            this.m_id = _arg1;
            var _local2:Component = this.createPhotoComponent();
            append(ASwingHelper.verticalStrut(4));
            append(_local2);
            append(ASwingHelper.verticalStrut(7));
            ASwingHelper.prepare(this);
        }
        private function createPhotoComponent():Component{
            var _local1:Player;
            if (this.m_id == Global.player.uid){
                _local1 = Global.player;
            } else {
                _local1 = Global.player.findFriendById(this.m_id);
            };
            var _local2:DisplayObject = new EmbeddedArt.hud_no_profile_pic();
            this.m_picContainer = new Sprite();
            var _local3:Sprite = (this.m_picContainer as Sprite);
            _local3.graphics.beginFill(0xFF0000, 0);
            _local3.graphics.drawRect(0, 0, 50, 50);
            _local3.graphics.endFill();
            this.m_picContainer.addChild(_local2);
            if (((((_local1) && (_local1.snUser))) && (_local1.snUser.picture))){
                LoadingManager.load(_local1.snUser.picture, this.photoCompleteHandler);
            };
            var _local4:Component = new AssetPane(this.m_picContainer);
            ASwingHelper.prepare(_local4);
            var _local5:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            _local5.appendAll(ASwingHelper.horizontalStrut(3), _local4);
            return (_local5);
        }
        private function photoCompleteHandler(_arg1:Event):void{
            var _local3:DisplayObject;
            var _local2:LoaderInfo = (_arg1.target as LoaderInfo);
            if (((_local2) && (_local2.loader))){
                _local3 = _local2.loader;
                _local3.width = (_local3.height = 50);
                this.m_picContainer.addChild(_local3);
            };
        }

    }
}//package Modules.franchise.display 
